// @ts-ignore
/* eslint-disable */
// import { request } from 'umi';
import request from '@/utils/request';

/** 退出登录接口 POST /api/login/outLogin */
export async function outLogin(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/login/outLogin', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 登录接口 POST /api/login/account */
// export async function login(body: API.LoginParams, options?: { [key: string]: any }) {
//   return request<API.LoginResult>('/api/login/account', {
//     method: 'POST',
//     headers: {
//       'Content-Type': 'application/json',
//     },
//     data: body,
//     ...(options || {}),
//   });
// }

/** 此处后端没有提供注释 GET /api/notices */
export async function getNotices(options?: { [key: string]: any }) {
  return request<API.NoticeIconList>('/api/notices', {
    method: 'GET',
    ...(options || {}),
  });
}

/** 获取规则列表 GET /api/rule */
export async function rule(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RuleList>('/api/rule', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 新建规则 PUT /api/rule */
export async function updateRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'PUT',
    ...(options || {}),
  });
}

/** 新建规则 POST /api/rule */
export async function addRule(options?: { [key: string]: any }) {
  return request<API.RuleListItem>('/api/rule', {
    method: 'POST',
    ...(options || {}),
  });
}

/** 删除规则 DELETE /api/rule */
export async function removeRule(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/rule', {
    method: 'DELETE',
    ...(options || {}),
  });
}

/** strive框架中的登录功能 */
export async function login(params: API.LoginParams) {
  return request<API.LoginResult>('/api/service/api-uaa/oauth/token', {
    method: 'POST',
    headers: {
      Accept: 'application/json',
      'Content-Type': 'application/json;charset=utf-8',
      Authorization: 'Basic ' + window.btoa('webApp' + ':' + 'webApp'),
    },
    params,
  });
}

/** strive框架中通过token获取当前用户 */
export async function currentUser() {
  return request<{
    data: API.CurrentUser;
  }>('/api/service/api-user/users/current', {
    method: 'GET',
  });
}

/** 获取用户菜单 */
export async function getMenus(roles: string) {
  return request(`/api/service/api-user/menus/${roles}`);
}

/** 获取当前用户菜单 */
export async function getMenusCurent(roles: string) {
  return request(`/api/service/api-user/menus/current/${roles.rolesValue}`);
}

//tokenLogin
// export async function tokenLogin(params:any) {
//   return request(`${securityCenterUrl}/api/loginToken`, {
//     method: 'POST',
//     data: params,
//   });
// }
